const express = require('express')
const app = express()
//数据库引入
require("./db")

app.use(express.json());
app.use(express.urlencoded());

//映入路由
const addAdmin = require('./router/addAdmin')
const adminList = require('./router/adminList')
const deleteAdmin = require("./router/deleteAdmin")
const login = require("./router/login")
const isLogin = require("./router/isLogin")
const logout = require("./router/logout")
const addAdv = require("./router/addAdv")
const findAdvList = require("./router/findAdvList")
const deleteAdvList = require("./router/deleteAdvList")
const getUpDateAdv = require("./router/getUpdateAdv")
const upDateAdv = require("./router/upDateAdv")
const path = require("path");
app.use(addAdmin)
//后端获取管理员列表
app.use(adminList)
//后端删除
app.use(deleteAdmin);
//加载登录路由
app.use(login)
//启动isLogin
app.use(isLogin)
//启动登出组件
app.use(logout)
//启用添加广告
app.use(addAdv)
//启动查询接口
app.use(findAdvList)
//暴露静态资源文件夹
app.use("/upload", express.static(path.resolve(__dirname, "./upload")))
//启动删除按钮删除功能
app.use(deleteAdvList)
//启动更新按钮点击功能
app.use(getUpDateAdv)
//启动更新数据功能"直接更新数据库内容"
app.use(upDateAdv)


app.listen("8327",()=>{
  console.log('服务器启动成功 http://localhost:8327')
})